package main.java.org.jmtp.sync.model;

import java.math.BigInteger;
import java.util.Date;

import jmtp.PortableDeviceAudioObject;


public class TrackImpl implements Track {
	private Long id;
	
	private String artist;
	private String title;
	private Long playCount;
	private String persistentId;
	private String album;
	private String zenId;
	private String filename;
	private BigInteger length;
	Date dateCreated;
	Date dateModified;
	private String deviceId;
	
	private TrackLocation location;
	
	public static void main(String[] argv) {
		
	}
	/**
	 * No argument constructor only used for hibernate
	 * Used by hibernate to instanciate Track with java.lang.reflect.Constructor.newInstance()
	 * Recomanded to have a package visibility
	 */
	private TrackImpl () {
		
	}
	/**
	 * Constructor of the Track
	 * @param pdao the PortableDeviceAudioObject used to populate the fields
	 * @param location TrackLocation of the track
	 * @param deviceId ID of the device. Null of Location
	 */
	public TrackImpl (PortableDeviceAudioObject pdao,TrackLocation location, String deviceId) {
		artist = pdao.getArtist();
		title = pdao.getTitle();
		playCount = pdao.getUseCount();
		persistentId = pdao.getPersistentUniqueIdentifier();
		album = pdao.getAlbum();
		zenId = pdao.getID();
		filename = pdao.getOriginalFileName();
		length = pdao.getDuraction();
		dateCreated = pdao.getDateCreated();
		dateModified = pdao.getDateModified();
		
		this.deviceId = deviceId;
		
		this.location = location;
	}
	
	public boolean equals(Object other) {
		if (this == other) { return true; }
		if (!(other instanceof TrackImpl)) { return false; }
		
		final TrackImpl track = (TrackImpl) other;
		
		if (track.persistentId == this.persistentId) { return true; }
		
		return false;
	}
	
	/***********/
	/* Getters */
	/***********/
	public TrackLocation getLocation() {
		return location;
	}
	public String getArtist() {
		return artist;
	}
	public String getTitle() {
		return title;
	}
	public Long getPlayCount() {
		return playCount;
	}
	public String getPersistentId() {
		return persistentId;
	}
	public String getAlbum() {
		return album;
	}
	public String getZenId() {
		return zenId;
	}
	public String getFilename() {
		return filename;
	}
	public BigInteger getLength() {
		return length;
	}
	public Date getDateCreated() {
		return dateCreated;
	}
	public Date getDateModified() {
		return dateModified;
	}
	public String getDeviceId() {
		return deviceId;
	}
	/**
	 * Only used for hibernate
	 * @return the id
	 */
	private Long getId() {
		return id;
	}
	/***********************************/
	/* Setters only used for Hibernate */
	/***********************************/
	@SuppressWarnings("unused")
	private void setLocation(TrackLocation location) {
		this.location = location;
	}
	@SuppressWarnings("unused")
	private void setArtist(String artist) {
		this.artist = artist;
	}
	@SuppressWarnings("unused")
	private void setPlayCount(Long playCount) {
		this.playCount = playCount;
	}
	@SuppressWarnings("unused")
	private void setTitle(String title) {
		this.title = title;
	}
	@SuppressWarnings("unused")
	private void setPersistentId(String persistentId) {
		this.persistentId = persistentId;
	}
	@SuppressWarnings("unused")
	private void setAlbum(String album) {
		this.album = album;
	}
	@SuppressWarnings("unused")
	private void setZenId(String zenId) {
		this.zenId = zenId;
	}
	@SuppressWarnings("unused")
	private void setFilename(String filename) {
		this.filename = filename;
	}
	@SuppressWarnings("unused")
	private void setLength(BigInteger length) {
		this.length = length;
	}
	@SuppressWarnings("unused")
	private void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	@SuppressWarnings("unused")
	private void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}
	@SuppressWarnings("unused")
	private void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}
	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}

}
